project(sportwatcher)

set(KDE4_BUILD_TESTS "ON")

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})

set(KDE_MIN_VERSION "4.2.0")
find_package(KDE4 4.2.0 REQUIRED)

set(GDAL_MIN_VERSION "1.5.4")
find_package(GDAL 1.5.4 REQUIRED)

set(LIBUSB_MIN_VERSION "0.1.12")
find_package(LIBUSB 0.1.12 REQUIRED)

set(FREETYPE_MIN_VERSION "9.20.3")
find_package(Freetype 9.20.3 REQUIRED)

set(MAPNIK_MIN_VERSION "0.6")
find_package(Mapnik 0.6 REQUIRED)
 
include (KDE4Defaults)
include (MacroWriteBasicCMakeVersionFile)
include (MacroLibrary)

add_definitions (${QT_DEFINITIONS} ${KDE4_DEFINITIONS} -DHAVE_CONFIG_H=1 -DQT3_SUPPORT)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} ${KDE4_INCLUDES} )

# create config.h
include (ConfigureChecks.cmake)
include (CheckIncludeFiles)

if (MAPNIK_FOUND)
   FIND_PROGRAM(MAPNIK_PLUGIN mapnik-plugin-base
      HINTS
         $ENV{MAPNIK_DIR}
         $ENV{MAPNIK_ROOT}
      PATH_SUFFIXES bin
      PATHS
         /sw
         /opt/local
         /opt/csw
         /opt
      )

   IF (MAPNIK_PLUGIN)
      execute_process(COMMAND ${MAPNIK_PLUGIN}
                   OUTPUT_VARIABLE MAPNIK_PLUGIN_PATH
      )

      if(MAPNIK_PLUGIN_PATH)
         string(REGEX REPLACE "\n" "" _plugin_path ${MAPNIK_PLUGIN_PATH})
         set(MAPNIK_PLUGIN_PATH ${_plugin_path})
      endif(MAPNIK_PLUGIN_PATH)

      set(MAPNIK_PLUGIN_BASE 1)
      set(MAPNIK_PLUGINS 1)
      set(MAPNIK_FONTS 1)
      message(STATUS "Found mapnik plugin path at ${MAPNIK_PLUGIN_PATH}")
   endif(MAPNIK_PLUGIN)
endif()

check_include_files(${GDAL_INCLUDE_DIR}/gdal.h HAVE_GDAL)
if(MAPNIK_FOUND)
   set(HAVE_MAPNIK 1)
endif(MAPNIK_FOUND)
configure_file (config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )

add_subdirectory(cmake)
add_subdirectory(libgant)
add_subdirectory(libgarmin)
add_subdirectory(src)
add_subdirectory(pics)
add_subdirectory(icons)
macro_optional_add_subdirectory(share)
macro_optional_add_subdirectory(doc)
macro_optional_add_subdirectory(po)

macro_display_feature_log()
